<template>
  <div>
    <div class="searchBox">
         <div class="label">班级：</div>
         <a-input  style="height:32px;width:360px;" v-model:value="deptName" placeholder="请输入班级"></a-input>
         <a-button type="primary" style="margin-left:15px;" @click="handleSearch" preIcon="ant-design:search-outlined"> 查询</a-button>
         <a-button type="primary" style="margin-left:15px;" @click="handleRest" preIcon="ic:baseline-restart-alt"> 重置</a-button>
    </div>
    <div class="tableBox">
        <BasicTable
        ref="tableRef"
        :columns="listColumns"
        :dataSource="dataSource"
        :border="true"
      >
        <template #tableTitle>
          <a-button  type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
        </template>
      </BasicTable>
    </div>
  </div>
</template>

<script lang="ts" name="dormitory-dormnumtotal" setup>
  import {ref, reactive, computed, unref,onMounted} from 'vue';
  import {BasicTable, useTable, TableAction} from '/@/components/Table';
  import {useModal} from '/@/components/Modal';
  import { useListPage } from '/@/hooks/system/useListPage'
  // import {columns, searchFormSchema} from './DormNumTotal.data';
  import {list,getExportUrl,totalScoreList} from './DormNumTotal.api';
  import { downloadFile } from '/@/utils/common/renderUtils';
  import { useUserStore } from '/@/store/modules/user';
  const queryParam = reactive<any>({});
  const checkedKeys = ref<Array<string | number>>([]);
  const userStore = useUserStore();

  const { prefixCls,tableContext,onExportXls,onImportXls } = useListPage({
    tableProps:{},
    exportConfig: {
            name:"宿舍数统计",
            url: getExportUrl,
            params: queryParam,
    },
  })

  const [registerTable, {reload},{ rowSelection, selectedRowKeys }] = tableContext

  //注册model
  const listColumns =  ref([
    {
      title: '班级',
      dataIndex: 'deptName',
    },
    {
      title: '宿舍总数',
      dataIndex: 'total',
    },
    {
      title: '本班宿舍数',
      dataIndex: 'own',
    },
     {
      title: '混合宿舍数',
      dataIndex: 'mix',
    },
  ])
  let dataSource = ref([])
  let rangeTime = ref([])

  function handleSearch(){
    getList()
  }
  function handleRest(){
    deptName.value = ''
    getList()
  }
  let deptName = ref('')
  function getList(){
    let data = {
      deptName : deptName.value
    }
    totalScoreList(data).then(res=>{
      console.log(res);
        dataSource.value = res
    })
  }
   /**
    * 成功回调
    */
  function handleSuccess() {
      (selectedRowKeys.value = []) && reload();
   }
   onMounted(()=>{
    getList()
   })
  


</script>

<style lang="less" scoped>
.searchBox{
  display: flex;
  align-items: center;
  background: #fff;
  margin: 10px;
  padding: 6px;
  height: 60px;
  .label{
    display: inline-flex;
    justify-content: flex-end;
    align-items: center;
    width: 130px;
    height: 32px;
    color: rgba(0, 0, 0, 0.88);
  }
}
.tableBox{
  background: #fff;
  padding: 6px;
  margin: 10px;
}

</style>